<?php
include "includes/ui.php";
$approve=0;
if (isset($_GET['t'])){
	if ($_GET['t']=='ap'){
		$approve=1;
		$name="อนุมัติขอซื้อสินค้า/พัสดุ";
		if ($_SESSION['permission'][$page]['ap']!="1") {
			echo "<meta http-equiv = refresh ; content = '0 ; url = request.php'>";
			exit();
		}
	}
}else {
	$name = "ขอซื้อสินค้า/พัสดุ";
	$approve=0;
}

echo headerHTML("stock", $name);

?> 

<input type="hidden" id="approve" value="<?php echo $approve; ?>" />
<div id="popup" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style='margin-left:-390px;width:800px;'>

    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3 id="myModalLabel"><i class="icon-cog"></i> ขอซื้อสินค้า/พัสดุ </h3>
    </div>

    <form class="form-horizontal" style="margin-bottom: 0px!important;">

        <div class="modal-body" style="overflow-y:auto;min-height:400px;">

            <div class="control-group">
                <label class="control-label" for="inputName"  style='width:120px !important;font-weight:bold;'><i class="icon-double-angle-right"></i> เลขที่ใบขอซื้อ</label>
                <div class="controls" style='margin-left:120px !important;'>
                
                    <input type="text" id="txtReqNo_" required maxlength="15">

                    <span class="help-inline" style="font-weight:bold;margin-left:80px;">วันที่ขอซื้อ&nbsp;</span>

                    <input class="span1" style="width:100px !important;" data-date-format="dd/mm/yyyy" id='txtRequestDate' required size="16" type="text"  readonly="">


                </div>
            </div>
            <div class="control-group">
                <label class="control-label" for="inputName"  style='width:120px !important;font-weight:bold;'><i class="icon-double-angle-right"></i> หมายเหตุ</label>
                <div class="controls" style='margin-left:120px !important;'>
                    <input type="text" id="txtRemark" class='span6' maxlength="300">

                </div>
            </div>
            <div class="well no-padding">
                <label class="control-label hidden_control" for="inputName"  style='width:120px !important;font-weight:bold;'><i class="icon-double-angle-right"></i> เลือกรายการ</label>
                <div style="padding:5px;background-color:#ffffff;" class='hidden_control'>
                    <select id='cboType' style='width:150px;'>
                    </select>
                    <input type="text" id="txtProduct"  data-provide="typeahead"  data-items="5" data-source="" class='span3' placeholder="...." />
                    <input type="text" id="txtAmount"   class='span1 text-right' value="1" maxlength="4" />
                    <button class="btn btn-inverse" rel="tooltip" title="" id='btnAddProduct' type='button'   data-original-title="เพิ่มรายการ" >เพิ่ม</button>
                </div>
                <span class="help-inline text-center" id='Error' style="display:none;font-weight:bold;margin: auto;text-align: center;width: 100%;color: red !important;background-color: white;">กรุณาเลือกรายการ&nbsp;</span>
                <!-- Add News: WYSIWYG Edior -->
                <table class="table" id='table_detail' style='width:100% !important;'>
                    <thead>
                        <tr>
                            <th style='color:#333 !important;width:30px;'>#</th>
                            <th style='color:#333 !important;display:none; '>0</th>
                            <th style='color:#333 !important;width:200px;' class='center'>ประเภท</th>
                            <th style='color:#333 !important;'>รายการพัสดุ/สินค้า</th>
                            <th style='color:#333 !important;width:120px;' class='center'>จำนวน</th>
                            <th style='color:#333 !important;width:40px;'>ลบ</th>
                        </tr>
                    </thead>
                    <tbody>

                    </tbody>
                </table>
                <!-- / Add News: WYSIWYG Edior -->

            </div> 
        </div>

        <div class="modal-footer">
			<button type='button' class="btn btn-success approve_control" id="btnApp">อนุมัติ</button>
			<button type='button' class="btn btn-warning approve_control" id="btnNotApp">ไม่อนุมัติ</button>
            <button type='submit' class="btn btn-primary hidden_control" id="btnSave">ส่งรายการ</button>
            <button class="btn" data-dismiss="modal" id='btnCancel' aria-hidden="true">ยกเลิก</button>

        </div>
    </form>

</div> 

 <div id="popupSave" class="modal hide fade" style="width:350px;top:35% !important;margin-left:-180px;" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

    <div class="modal-header" style='padding-top:20px;padding-bottom:25px;'>
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3 id="myModalLabel" style="color:#72a9c9;"><img src='img/info1.png' width='24px'/> คุณต้องการบันทึกข้อมูล ?</h3>
    </div>
  
    <div class="modal-footer center" style="text-align:center !important;padding-top:15px;padding-bottom:15px;">
        <button type='button'  class="btn btn-primary" id="btnConfirm">ตกลง</button>
        <button class="btn" data-dismiss="modal" aria-hidden="true">ยกเลิก</button>
    </div>
 
</div> 
<!-- Live Stats -->
<div class="row-fluid">

    <!-- Pie: Box -->
    <div class="span12">

        <!--  : Top Bar -->
        <div class="top-bar">
            <h3><i class="icon-cog"></i> <?php echo $name;?></h3>
            <?php
            if ($approve != 1) {
                ?>
                <div class='tmp' style='float:right'>
                    <a href="#popup" data-toggle="modal">
                        <button class="btn btn-info" rel="tooltip" title=""   data-original-title="สร้างรายการขอซื้อ"  id='btnAdd' tooltip="Add">ขอซื้อพัสดุ</button>
                    </a>
                </div>
            <?php } ?>
        </div>
        <!-- /  : Top Bar -->

        <!-- Pie: Content -->
        <div class="well no-padding">
            <div class="span12">
                <div class="row-fluid">
                    <form class="form-horizontal">
                        <div class='span12'>
                            <div class="control-group" style='border-bottom:0px;padding-bottom:5px;'>
                                <label class="control-label" style='padding-top:5px;' for="inputName"><i class="icon-double-angle-right"></i>หมายเลขขอซื้อ</label>
                                <div class="controls">
                                    &nbsp;&nbsp;&nbsp;<input type="text" id="txtReqNo" placeholder="RQ" maxlength="15">
                                    <?php
                                    if ($approve == 1) {
                                        ?>
                                        <span class="help-inline" style="font-weight:bold;margin-left:70px;">ชื่อ-นามสกุล&nbsp;</span>
                                        &nbsp;&nbsp;&nbsp;<input type="text" id="txtEmployee" placeholder="ชื่อ-นามสกุล" maxlength="100">
                                    <?php } ?>
                                </div>
                            </div>

                            <div class="control-group" style="border-bottom:0px;padding-bottom:10px;">
                                <label class="control-label" style='padding-top:5px;'><i class="icon-double-angle-right"></i>สถานะ</label>
                                <div class="controls">
                                    &nbsp;&nbsp;&nbsp;<select class="no-margin span8" id='cboRequets' style="width:210px !important;">
                                    </select>

                                    <span class="help-inline" style="font-weight:bold;margin-left:70px;">วันที่ขอซื้อ&nbsp;</span>
                                    &nbsp;&nbsp;&nbsp;
                                    <div class="input-append date btndate1"   data-date="12-02-2012"  data-date-format="dd/mm/yyyy">
                                        <input class="span1" style="width:100px !important;" id='txtDateFrom_s' size="16" type="text"  readonly="">
                                        <span class="add-on"><i class="icon-calendar"></i></span>
                                    </div>

                                    &nbsp;
                                    <div class="input-append date btndate2"   data-date="12-02-2012"  data-date-format="dd/mm/yyyy">
                                        <input class="span1" style="width:100px !important;" id='txtDateTo_s' size="16" type="text"  readonly="">
                                        <span class="add-on"><i class="icon-calendar"></i></span>
                                    </div>

                                    <button class="btn btn-inverse" type='button' id='btnSearch' style='height:30px;margin-left:50px;margin-top:0px;padding-top:0px;' rel="tooltip" title=""   data-original-title="ค้นหาข้อมูล"><i class="icon-search"></i></button> 

                                </div>

                            </div>

                        </div>
                    </form>
                </div>
            </div>
            <table class="data-table" id='resultData'>
                <thead style='border-top:1px solid #c2c2c2;border-bottom:1px solid #c2c2c2;'> 
                    <tr >
                        <th style='color:#333 !important;width:40px !important;'>#</th>
                        <th style='color:#333 !important;display:none'>0</th>
                        <th style='color:#333 !important;width:100px !important;' class='center'>วันที่</th>
                        <th style='color:#333 !important;' class='center'> เลขที่ใบขอซื้อ</th>
                        <th style='color:#333 !important;' class='text-center'> ชื่อผู้ขอซื้อ</th>
                        <th style='color:#333 !important;width:180px; !important' class="center">จำนวนรายการ</th>
                        <th style='color:#333 !important;width:150px; !important' class="center">สถานะ </th>
                        <th style='color:#333 !important;display:none'>0</th>
                        <th style='color:#333 !important;width:70px !important;' class="center">ดูรายการ </th>
                        <th style='color:#333 !important;width:50px !important;' class="center">ลบ </th>
                    </tr>
                </thead>
                <tbody>

                </tbody>

            </table>

        </div>
        <!-- / Pie: Content -->

    </div>
    <!-- / Pie -->

</div>
<!-- / Live Stats -->

<?php
echo footerHTML();
?>

<!-- Javascript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src='js/jquery.hotkeys.js'></script>
<!--script src='js/fullcalendar.min.js'></script-->
<script src="js/jquery-ui-1.10.2.custom.min.js"></script>
<script src="js/jquery.pajinate.js"></script>
<!--script src="js/jquery.prism.min.js"></script-->
<script src="js/jquery.dataTables.js"></script>

<script src="js/jquery.flot.resize.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/bootstrap-wysiwyg.js"></script>
<script src="js/bootstrap-typeahead.js"></script>
<script src="js/jquery.easing.min.js"></script>
<script src="js/jquery.chosen.min.js"></script>
<script src="js/avocado-custom.js"></script>
<script src="js/jqBootstrapValidation.js"></script>
<script src="js/bootstrap-datepicker.js"></script>
<script src="js/myScript/js_request.js"></script>

</html>